package org.aeon.service.impl;

import org.aeon.dao.UserMessageDao;
import org.aeon.dao.impl.UserMessageDaoImpl;
import org.aeon.entity.ChatMessage;
import org.aeon.service.UserMessageService;

import java.util.Date;
import java.util.List;

/**
 * @author: MissingAeon
 * @date: 2024/1/27 9:31
 * @description:
 */
public class UserMessageServiceImpl implements UserMessageService {


    @Override
    public boolean writeMessages(ChatMessage message, Long userId) {
        UserMessageDao userMessageDao = new UserMessageDaoImpl();
        final int i = userMessageDao.insert(userId, message);
        return i > 0;
    }

    @Override
    public List<ChatMessage> readMessagesByTimeToRange(Long userId, Long targetId, Long start, int count) {
        UserMessageDao userMessageDao = new UserMessageDaoImpl();
        return userMessageDao.read(userId, targetId, start, count);
    }

    @Override
    public List<ChatMessage> readMessagesByTime(Long userId, Long targetId, Date date) {
        UserMessageDao userMessageDao = new UserMessageDaoImpl();
        return userMessageDao.read(userId, targetId, date);
    }
}
